<template>
  <NuxtLink class="cursor-pointer" v-bind="linkattr">
    <slot></slot>
  </NuxtLink>
</template>
<script setup lang="ts">
import type { NuxtLinkProps } from "nuxt/app";
const route = useRoute();
type LinkProps = NuxtLinkProps & {
  noPrereth?: boolean;
  to: string;
};
type Prettify<T> = {
  [k in keyof T]: T[k];
};
type MyLinkProp = Prettify<LinkProps>;
const props = withDefaults(defineProps<LinkProps>(), {
  // noPrefetch: true,
});

defineSlots<{
  default: any;
  // leftIcon: any;
}>();
const emit = defineEmits<{
  // (e: "change", id: number): void;
  // (e: "update", value: string): void;
}>();
const linkattr = computed(() => {
  let { noPrefetch, prefetch, to = "/", ...others } = props;
  let params: LinkProps = {
    to,
  };
  if (noPrefetch) {
    params.noPrefetch = noPrefetch;
  }
  if (prefetch) {
    params.prefetch = prefetch;
  }
  if (params.to) {
    to = `${to || "/"}`;
  }

  return {
    ...others,
    ...params,
  };
});
</script>
<script lang="ts">
export default defineComponent({
  inheritAttrs: true,
});
</script>
<style lang="scss" scoped></style>
